home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / global-one-water.swf / scripts / __Packages / SoundManager.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  1.7 KB  |  79 lines

  1. class SoundManager extends Snd
  2. {
  3.    var sounds;
  4.    var mc_holder;
  5.    var muted = false;
  6.    var curVol = 100;
  7.    function SoundManager(hld_mc)
  8.    {
  9.       super();
  10.       this.sounds = new Object();
  11.       this.mc_holder = !hld_mc ? _root : hld_mc;
  12.    }
  13.    function playAndRemove(snd_id, offset, loops)
  14.    {
  15.       offset = !isNaN(offset) ? offset : 0;
  16.       loops = !isNaN(loops) ? loops : 0;
  17.       var _loc2_ = this.newSound(snd_id);
  18.       _loc2_.start(offset,loops);
  19.       _loc2_.onSoundComplete = _loc2_.remove;
  20.       return _loc2_;
  21.    }
  22.    function clearAllSounds()
  23.    {
  24.       for(var _loc2_ in this.sounds)
  25.       {
  26.          this.sounds[_loc2_].remove();
  27.       }
  28.    }
  29.    function newSound()
  30.    {
  31.       var _loc5_ = this.mc_holder.getNextHighestDepth();
  32.       var _loc6_ = this.mc_holder.createEmptyMovieClip("sh_mc" + _loc5_,_loc5_);
  33.       var _loc4_ = new Snd(_loc6_,this);
  34.       var _loc3_ = 0;
  35.       while(_loc3_ < arguments.length)
  36.       {
  37.          if(arguments[_loc3_] != undefined)
  38.          {
  39.             _loc4_.attachSound(arguments[_loc3_]);
  40.          }
  41.          _loc3_ = _loc3_ + 1;
  42.       }
  43.       this.sounds[_loc5_] = _loc4_;
  44.       return _loc4_;
  45.    }
  46.    function deleteSound(snd)
  47.    {
  48.       snd.remove();
  49.    }
  50.    function setVolume(vol)
  51.    {
  52.       if(this.muted)
  53.       {
  54.          this.curVol = vol;
  55.       }
  56.       else
  57.       {
  58.          super.setVolume(vol);
  59.       }
  60.    }
  61.    function get mute()
  62.    {
  63.       return this.muted;
  64.    }
  65.    function set mute(b)
  66.    {
  67.       this.muted = b;
  68.       if(b)
  69.       {
  70.          this.curVol = this.getVolume();
  71.          super.setVolume(0);
  72.       }
  73.       else
  74.       {
  75.          super.setVolume(this.curVol);
  76.       }
  77.    }
  78. }
  79.